from pydantic import BaseModel, Field
from datetime import datetime
from models.enums import OrderStatus, PaymentChannel, PaymentStatus

class OrderCreate(BaseModel):
    """模拟的订单表创建参数"""
    total_amount: float = Field(..., gt=0)
    actual_amount: float = Field(..., gt=0)
    channel: PaymentChannel

class PaymentCreateResponse(BaseModel):
    """订单表和支付表创建的响应字段"""
    order_id: int
    payment_id: int
    channel: PaymentChannel
    payment_url: str | None = None
    qr_code: str | None = None
    direct_result: bool = False  # 是否直接返回结果（余额支付）

class PaymentStatusResponse(BaseModel):
    """支付状态查询的响应字段"""
    order_id: int
    payment_id: int
    status: PaymentStatus
    amount: float | None = None
    channel: PaymentChannel
    payment_url: str | None = None
    qr_code: str | None = None
    direct_result: bool = False # 是否直接返回结果（余额支付）
    created_at: datetime
    updated_at: datetime

class PaymentNotify(BaseModel):
    """支付宝通知参数"""
    # 支付宝通知参数
    notify_time: datetime
    notify_type: str
    notify_id: str
    app_id: str
    charset: str
    version: str
    sign_type: str
    sign: str
    trade_no: str
    out_trade_no: str
    trade_status: str
    total_amount: float
    buyer_id: str | None = None
    # 其他可选字段...

class PaymentCancelResponse(BaseModel):
    """取消支付的响应字段"""
    order_id: int
    payment_id: int
    status: PaymentStatus
    message: str